﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using Model;
using Model.FA_DataSetTableAdapters;
using Model.IRepository;
using System.Data.SqlClient;
using System.Data;

namespace Model.Repository
{
    public class UserRepository : _IUserRepository
    {
        UsersTableAdapter _adapter;

        public UserRepository()
        {
            _adapter = new UsersTableAdapter();
        }

        public void CreateUser()
        {
            try
            {
            }
            catch (Exception ex)
            {
            }
        }

        public void UpdateUser()
        {
            try
            {
            }
            catch (Exception ex)
            {
            }
        }

        public void DeleteUser()
        {
            try
            {
            }
            catch (Exception ex)
            {
            }
        }

        public FA_DataSet.UsersDataTable GetUser()
        {
            try
            {
                return _adapter.GetUsersData();                
            }
            catch (Exception ex)
            {
                return null;
            }
        }


        public FA_DataSet.UsersDataTable IsAuthenticatedUser(string Username, string Password)
        {
            try
            {
                return _adapter.IsAuthenticatedUser(Username, Password);
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public bool IsUsernameAvailable(string Username)
        {
            try
            {
                var result =(_adapter.IsUsernameAvailable(Username).Count != 0) ? false : true;
                return result;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }
}